package com.eric.text;

import java.util.Iterator;
import java.util.List;

import org.ansj.app.keyword.KeyWordComputer;
import org.ansj.app.keyword.Keyword;
import org.ansj.library.UserDefineLibrary;
import org.jsoup.nodes.Document;

public class AnsjAbstractWorker extends AbstractTextWorker {

	KeyWordComputer key;

	public AnsjAbstractWorker(Object input) {
		super(input);
	}

	@SuppressWarnings("rawtypes")
	@Override
	public void produce() {
		init();
		initThis();
		Iterator it = key.computeArticleTfidf(text).iterator();
		while (it.hasNext()) {
			Keyword k = (Keyword) it.next();
			result.add(k.getName() + "=" + k.getScore());
			System.out.println(k.getName() + "=" + k.getScore());
		}

	}

	@Override
	protected void initThis() {
		if (customWords.size() > 0) {
			for (String s : customWords) {
				UserDefineLibrary.insertWord(s);
			}
		}

		key = new KeyWordComputer(topN);
	}

	@Override
	public List<String> getContext() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<String> produce(String text, Document doc) {
		// TODO Auto-generated method stub
		return null;
	}

}
